package org.ikross.twitter.connector.factory;

import org.ikross.twitter.connector.IConnector;
import org.ikross.twitter.exception.IllegalConnectorArgumentException;
import org.ikross.twitter.exception.IllegalConnectorFactoryArgumentException;
import org.ikross.twitter.exception.MalformedURLConnectorException;
import org.ikross.twitter.exception.ConnectorException;
import org.ikross.twitter.session.Session;

/**
 * 
 * @author Kiko
 *
 */
public abstract class ConnectorFactory implements IConnectorFactory {
	
	private Session session;
	protected String formatExtension;
	
	public ConnectorFactory(){
		this.session = null;
		this.formatExtension = "";
	}
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#setSession(org.ikross.twitter.session.Session)
	 */
	public void setSession(Session session) throws IllegalConnectorFactoryArgumentException{
		if(this.getSession() != null)
			throw new IllegalConnectorFactoryArgumentException("This "+this.getClass().getName()+" already have a "+Session.class.getName());
		if(session == null)
			throw new IllegalConnectorFactoryArgumentException("The session must not be null");
		
		this.session = session;
	}
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#getSession()
	 */	
	public Session getSession(){
		return this.session;
	}
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#destroySession()
	 */
	public void destroySession() {
		this.session.destroy();
		this.session=null;
	}
	
	protected abstract String getFormatExtension();
	
	protected abstract void setFormatExtension(String formatExtension);

	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createPublicTimeLineConnector()
	 */
	public abstract IConnector createPublicTimeLineConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createFriendsTimeLineConnector()
	 */
	public abstract IConnector createFriendsTimeLineConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUserTimeLineConnector()
	 */
	public abstract IConnector createUserTimeLineConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetUpdateConnector(java.lang.String)
	 */
	public abstract IConnector createGetUpdateConnector(String idUpdate) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUpdateConnector(java.lang.String)
	 */
	public abstract IConnector createUpdateConnector(String status) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetRepliesConnector()
	 */
	public abstract IConnector createGetRepliesConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createDestroyUpdateConnector(java.lang.String)
	 */
	public abstract IConnector createDestroyUpdateConnector(String idUpdate) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetFriendsConnector()
	 */
	public abstract IConnector createGetFriendsConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetFollowersConnector()
	 */
	public abstract IConnector createGetFollowersConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetFeaturedUsersConnector()
	 */
	public abstract IConnector createGetFeaturedUsersConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetUserConnector(java.lang.String)
	 */
	public abstract IConnector createGetUserConnector(String id) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetReceivedDirectMessagesConnector()
	 */
	public abstract IConnector createGetReceivedDirectMessagesConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetSentDirectMessagesConnector()
	 */
	public abstract IConnector createGetSentDirectMessagesConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createSendDirectMessageConnector(java.lang.String, java.lang.String)
	 */
	public abstract IConnector createSendDirectMessageConnector(String recipient, String message) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createDestroyDirectMessageConnector(java.lang.String)
	 */
	public abstract IConnector createDestroyDirectMessageConnector(String idDirectMessage) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createNewFriendshipConnector(java.lang.String)
	 */
	public abstract IConnector createNewFriendshipConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createDestroyFriendshipConnector(java.lang.String)
	 */
	public abstract IConnector createDestroyFriendshipConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createConfirmFriendshipConnector(java.lang.String, java.lang.String)
	 */
	public abstract IConnector createConfirmFriendshipConnector(String idUserA, String idUserB) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createVerifyCredentialsConnector()
	 */
	public abstract IConnector createVerifyCredentialsConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createEndSessionConnector()
	 */
	public abstract IConnector createEndSessionConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetArchiveConnector()
	 */
	public abstract IConnector createGetArchiveConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUpdateLocationGETConnector(java.lang.String)
	 */
	public abstract IConnector createUpdateLocationGETConnector(String location) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUpdateLocationPOSTConnector(java.lang.String)
	 */
	public abstract IConnector createUpdateLocationPOSTConnector(String location) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUpdateDeliveryDeviceConnector(java.lang.String)
	 */
	public abstract IConnector createUpdateDeliveryDeviceConnector(String deliveryDevice) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createRateLimitStatusConnector()
	 */
	public abstract IConnector createRateLimitStatusConnector() throws MalformedURLConnectorException, ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createGetFavoritesConnector()
	 */
	public abstract IConnector createGetFavoritesConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createSetFavoriteConnector(java.lang.String)
	 */
	public abstract IConnector createSetFavoriteConnector(String idUpdate) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createDestroyFavoriteConnector(java.lang.String)
	 */
	public abstract IConnector createDestroyFavoriteConnector(String idUpdate) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createFollowUserConnector(java.lang.String)
	 */
	public abstract IConnector createFollowUserConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUnfollowUserConnector(java.lang.String)
	 */
	public abstract IConnector createUnfollowUserConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createBlockUserConnector(java.lang.String)
	 */
	public abstract IConnector createBlockUserConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createUnblockUserConnector(java.lang.String)
	 */
	public abstract IConnector createUnblockUserConnector(String idUser) throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createTestConnector()
	 */
	public abstract IConnector createTestConnector() throws ConnectorException;
	
	/* (non-Javadoc)
	 * @see org.ikross.twitter.connector.factory.IConnectorFactory#createDowntimeScheduleConnector()
	 */
	public abstract IConnector createDowntimeScheduleConnector() throws ConnectorException;
}